﻿@using Kugar.Core.BaseStruct
@using Kugar.Core.Web
@using Kugar.MVC.DaemonUI.Enums
@using Kugar.MVC.DaemonUI.Helpers
@using WS.FlowAuth.Web.Data.EF

@{
    ViewBag.Title = "授权码记录";
    Layout = "~/Areas/Admin/Views/Shared/Layout.cshtml";

    var lst = (VM_PagedList<log_AuthCode>)ViewBag.List;
    var keyword = Request.GetString("Keyword", "");
    var startDt = (DateTime?)ViewBag.StartDt;
    var endDt = (DateTime?)ViewBag.EndDt;
    var userCodes = (base_UserCode[]) ViewBag.UserCodes;
}

@section ContentBody
{
    @using (var page=WebUI.CustomPage.DataListPage<log_AuthCode>().Render())
    {
        using (page.FilterBlock.Render())
        {
            @WebUI.Form.DateRangePicker().Label("创建时间").Css("col-xs-6").LabelWidth(5).StartFieldName("StartDt").EndFieldName("EndDt").StartValue(startDt).EndValue(endDt).Type(DateTimePickerType.Date).Render()

            @WebUI.Form.TextWithButton().Name("Keyword").Css("col-xs-6").Value(keyword).ButtonTitle("搜索").ButtonStyle(ButtonStyleType.Primary).Value(keyword).Render()
        }

        using (var db=page.DataBlock.Render())
        {
            using (var tbl=db.Table().Data(lst).Render())
            {
                @tbl.Columns.AddIndex()

                @tbl.Columns.AddText().Title("用户代码").Value(x=>string.Format("<a href='/Admin/AuthLog/List?keyword={0}'>{0}</a>", userCodes.FirstOrDefault(y => y.UserCodeID == x.UserCodeID)?.UserCode))

                @tbl.Columns.AddText().Title("客户名称").Value(x=> userCodes.FirstOrDefault(y => y.UserCodeID == x.UserCodeID)?.CustomerName)

                @tbl.Columns.AddText().Title("创建时间").Value(x=>x.CreateDt.ToString("yyyy-MM-dd HH:mm"))

                @tbl.Columns.AddText().Title("机器码").Value(x=> string.Format("<a href='/Admin/AuthLog/List?keyword={0}'>{0}</a>", x.MachineCode) )

                @tbl.Columns.AddText().Title("授权码").Value(x=>x.AuthCode)

                @tbl.Columns.AddText().Title("流量计序号").Value(x=> string.Format("<a href='/Admin/AuthLog/List?keyword={0}'>{0}</a>", x.FlowNo) )

                @tbl.Columns.AddText().Title("操作码").Value(x=> string.Format("<a href='/Admin/AuthLog/List?keyword={1}'>{0}</a>", WS.FlowAuth.Converter.Converter.ConvertOpCode(x.OptCode), x.OptCode))

                @(tbl.Columns.AddDropDownList().Title("操作")
                      .AddButton((data,btn)=>btn.Title("详情").ShowModal($"/Admin/AuthLog/Detail?LogID={data.LogID}"))
                      //.AddCommandItem((data,btn)=>btn.Title("删除").Args(new {data.LogID }).CmdName("delete").Tips("是否确定删除").Url("MethodHandler"))
                      )
            }
        }

    }

}

@section Styles
{
    <style>
        .pagination > .active > a {
            background-color: #c0e2ff;
            border-color: #c0e2ff;
        }

    </style>

}
